

<!DOCTYPE html>
<html lang="zh" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/walker_sue/img/favicon.png">
  <link rel="icon" type="image/png" href="/walker_sue/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="lk">
  <meta name="keywords" content="">
  <title>常见规划问题（一） - Walker_Sue</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/walker_sue/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/github-gist.min.css" />
    
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/walker_sue/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/walker_sue/js/utils.js" ></script>
  <script  src="/walker_sue/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.3.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/walker_sue/">&nbsp;<strong>Walker</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/walker_sue/">
                <i class="iconfont icon-home-fill"></i>
                主页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/walker_sue/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/walker_sue/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/walker_sue/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/walker_sue/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="iconfont icon-books"></i>
                文档
              </a>
              <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                
                  
                  
                  
                  <a class="dropdown-item" target="_blank" rel="noopener" href="https://hexo.fluid-dev.com/">
                    
                    主题博客
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" target="_blank" rel="noopener" href="https://hexo.fluid-dev.com/docs/guide/">
                    
                    配置指南
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" target="_blank" rel="noopener" href="https://hexo.fluid-dev.com/docs/icon/">
                    
                    图标用法
                  </a>
                
              </div>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner intro-2" id="background" parallax=true
         style="background: url('/walker_sue/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container page-header text-center fade-in-up">
    <span class="h2" id="subtitle">
    
</span>




<div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2021-05-27 13:49" pubdate>
        May 27, 2021 pm
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.7k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      19
       分钟
    </span>
  

  
  
</div>


</div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto" id="post">
            <!-- SEO header -->
            <h1 style="display: none">常见规划问题（一）</h1>
            
            <div class="markdown-body" id="post-body">
              <div align='center' ><font size='10'>机器学习-BI</font></div>

<hr>
<div align='center' ><font size='5'>Week_13</font></div>
<div align='center' ><font size='5'>常见规划问题（一）</font></div>

<hr>
<h3 id="1-规划问题的分类"><a href="#1-规划问题的分类" class="headerlink" title="1.规划问题的分类"></a><strong>1.规划问题的分类</strong></h3><ul>
<li><strong>线性规划：</strong> 在一组线性约束条件的限制下，求一线性目标函数最大或最小的问题； <br></li>
<li><strong>整数规划：</strong>当约束条件加强，要求所有的自变量必须是整数时，成为整数规划（特别地，自变量只能为0或1时称为0-1规划）； <br></li>
<li><strong>非线性规划：</strong>无论是约束条件还是目标函数出现非线性项，那么规划问题就变成了非线性规划； <br></li>
<li><strong>多目标规划：</strong>在一组约束条件的限制下，求多个目标函数最大或最小的问题； <br></li>
<li><strong>动态规划：</strong>将优化目标函数分多阶段，利用阶段间的关系逐一进行求解的方法； <br></li>
<li><strong>应用举例：</strong>旅行商问题、车辆路径规划问题、运输问题、最短路问题、最大流问题、中国邮递员问题 <br></li>
</ul>
<h3 id="2-线性规划模型的三要素"><a href="#2-线性规划模型的三要素" class="headerlink" title="2.线性规划模型的三要素"></a><strong>2.线性规划模型的三要素</strong></h3><p>线性规划模型主要包括三个部分：决策变量、目标函数、约束条件 <br></p>
<p><strong>决策变量</strong>  <br><br>决策变量是指问题中可以改变的量，例如生产多少货物，选择哪条路径等；线性规划的目标就是找到最优的决策变量。 <br><br>在线性规划中决策变量包括实数变量，整数变量，0-1变量等。 <br></p>
<p><strong>目标函数</strong> <br><br><img src="01.png" srcset="/walker_sue/img/loading.gif"></p>
<h3 id="3-线性规划模型的数学表示"><a href="#3-线性规划模型的数学表示" class="headerlink" title="3.线性规划模型的数学表示"></a><strong>3.线性规划模型的数学表示</strong></h3><p><img src="02.png" srcset="/walker_sue/img/loading.gif"><br><img src="03.png" srcset="/walker_sue/img/loading.gif"></p>
<h4 id="图解法"><a href="#图解法" class="headerlink" title="图解法"></a><strong>图解法</strong></h4><p>对于较为简单且只有两个决策变量的线性规划问题可以使用图解法。<br><br><img src="04.png" srcset="/walker_sue/img/loading.gif"><br><img src="05.png" srcset="/walker_sue/img/loading.gif"></p>
<h4 id="单纯形法"><a href="#单纯形法" class="headerlink" title="单纯形法"></a><strong>单纯形法</strong></h4><p><strong>对于决策变量比较多的线性规划模型，图解法不再适用。</strong> <br><br>单纯形法是1947 年G. B. Dantzig提出的一种十分有效的求解方法，极大地推广了线性规划的应用，直到今日也在一些线性规划的求解器中使用。<br></p>
<p>从图解法的例子中，我们可以看出，约束条件所围成的区域为一个<strong>凸多边形</strong>，当决策变量多于两个时，约束条件围成的区域为一个<strong>凸多面体</strong>，称之为<strong>可行域</strong>。其中每一个面（称之为<strong>超平面</strong>）即代表一个约束条件。<br><br>单纯形法的思路就是在可行域的一个顶点处找到一个<strong>初始可行解</strong>，<strong>判断该解是不是最优</strong>，若不是，则<strong>迭代到下一个顶点处</strong>进行重复判断。因为最优解的搜索范围从整个可行域缩小到了可行域的有限个顶点，算法的效率得到了极大的提升。<br><br><img src="06.png" srcset="/walker_sue/img/loading.gif"></p>
<h3 id="4-使用python求解简单线性规划模型"><a href="#4-使用python求解简单线性规划模型" class="headerlink" title="4.使用python求解简单线性规划模型"></a><strong>4.使用python求解简单线性规划模型</strong></h3><h4 id="编程思路"><a href="#编程思路" class="headerlink" title="编程思路"></a><strong>编程思路</strong></h4><p><strong>1. 选择适当的决策变量</strong></p>
<p>在解决实际问题时，把问题归结成一个线性规划数学模型是很重要的一步，但往往也是困难的一步，模型建立得是否恰当，直接影响到求解。而选适当的决策变量，是我们建立有效模型的关键之一。</p>
<p><strong>2.将求解目标简化为求一个目标函数的最大/最小值</strong></p>
<p>能把要求解的问题简化为一个最值问题是能否使用线性规划模型的关键，如果这一点不能达到，之后的工作都有没有意义的。</p>
<p><strong>3. 根据实际要求写出约束条件（正负性，资源约束等）</strong></p>
<p>线性规划的约束条件针对不同的问题有不同的形式，总结来说有以下三种：等式约束、不等式约束、符号约束</p>
<h4 id="A-scipy使用"><a href="#A-scipy使用" class="headerlink" title="A. scipy使用:"></a><strong>A. scipy使用</strong>:</h4><p><strong>Step1: 导入相关库</strong></p>
<pre><code class="hljs pyhton">import numpy as np
from scipy import optimize as op</code></pre>
<p><strong>Step2: 定义决策变量</strong></p>
<pre><code class="hljs python"><span class="hljs-comment"># 给出变量取值范围</span>
x1=(<span class="hljs-number">0</span>,<span class="hljs-literal">None</span>)  
x2=(<span class="hljs-number">0</span>,<span class="hljs-literal">None</span>)
x3=(<span class="hljs-number">0</span>,<span class="hljs-literal">None</span>)</code></pre>
<p><strong>Step3: 将原问题化为标准形式</strong></p>
<p>注意：编程时默认为最小化目标函数，因此这里改为 ；第二个约束为大于等于约束，这里化为小于等于约束；</p>
<p><strong>Step4: 定义目标函数系数和约束条件系数</strong></p>
<pre><code class="hljs python">c=np.array([-<span class="hljs-number">2</span>,-<span class="hljs-number">3</span>,<span class="hljs-number">5</span>])   <span class="hljs-comment"># 目标函数系数,3x1列向量</span>

A_ub=np.array([[-<span class="hljs-number">2</span>,<span class="hljs-number">5</span>,-<span class="hljs-number">1</span>],[<span class="hljs-number">1</span>,<span class="hljs-number">3</span>,<span class="hljs-number">1</span>]]) <span class="hljs-comment"># 不等式约束系数A，2x3维矩阵</span>
B_ub=np.array([-<span class="hljs-number">10</span>,<span class="hljs-number">12</span>])  <span class="hljs-comment"># 等式约束系数b, 2x1维列向量</span>
A_eq=np.array([[<span class="hljs-number">1</span>,<span class="hljs-number">1</span>,<span class="hljs-number">1</span>]])  <span class="hljs-comment"># 等式约束系数Aeq，3x1维列向量</span>
B_eq=np.array([<span class="hljs-number">7</span>])   <span class="hljs-comment"># 等式约束系数beq，1x1数值</span></code></pre>
<p><strong>Step5: 求解</strong></p>
<pre><code class="hljs pyhton">res&#x3D;op.linprog(c,A_ub,B_ub,A_eq,B_eq,bounds&#x3D;(x1,x2,x3)) #调用函数进行求解
res</code></pre>
<pre><code class="hljs pyhton">con: array([0.])
     fun: -14.571428571428571
 message: &#39;Optimization terminated successfully.&#39;
     nit: 3
   slack: array([0.        , 3.85714286])
  status: 0
 success: True
       x: array([6.42857143, 0.57142857, 0.        ])</code></pre>
<h4 id="B-pulp工具"><a href="#B-pulp工具" class="headerlink" title="B. pulp工具"></a><strong>B. pulp工具</strong></h4><pre><code class="hljs python">LpProblem类，用来构造LP问题实例
LpProblem(name=<span class="hljs-string">&#x27;NoName&#x27;</span>, sense=LpMinimize)
Name，指定问题名，输出信息用
Sense，LpMinimize或LpMaximize，代表目标是极大值还是极小值
solve()函数
在对LpProblem添加完约束条件后，调用solve进行求解
lpSum(vector) 
用于计算序列的求和，执行比<span class="hljs-built_in">sum</span>函数快
LpVariable类 ，用来构造LP问题中的变量
LpVariable(name, lowBound=<span class="hljs-literal">None</span>, upBound=<span class="hljs-literal">None</span>, cat=<span class="hljs-string">&#x27;Continuous&#x27;</span>, e=<span class="hljs-literal">None</span>) 
name指定变量名，lowBound(默认负无穷)和upBound(默认正无穷)是下界和上界，cat用来指定变量是离散(Integer,Binary)还是连续(Continuous) 
dicts(name, indexs, lowBound=<span class="hljs-literal">None</span>, upBound=<span class="hljs-literal">None</span>, cat=<span class="hljs-string">&#x27;Continuous&#x27;</span>, indexStart=[]) 
用来构造变量字典，批量创建Lp变量实例
name指定所有变量的前缀, index是列表，会用来构成变量名，参数lowBound, upbound, cat和LbVariable一样</code></pre>
<h4 id="C-Ortools求解器"><a href="#C-Ortools求解器" class="headerlink" title="C. Ortools求解器"></a><strong>C. Ortools求解器</strong></h4><pre><code class="hljs python">线性规划，默认使用GLOP
整数规划，默认使用CBC（Coin-<span class="hljs-keyword">or</span> branch <span class="hljs-keyword">and</span> cut），还包括SCIP、GLPK、Gurobi等
开源求解器，在计算性能和规模上弱于商业求解器，适用于中小企业及普通问题
<span class="hljs-comment"># 求解器定义</span>
solver = pywraplp.Solver.CreateSolver(<span class="hljs-string">&#x27;SCIP&#x27;</span>)
solver= pywraplp.Solver(<span class="hljs-string">&#x27;AssignmentProblem&#x27;</span>, pywraplp.Solver.GLOP_LINEAR_PROGRAMMING)
solver = pywraplp.Solver(<span class="hljs-string">&#x27;AssignmentProblem&#x27;</span>, pywraplp.Solver.CBC_MIXED_INTEGER_PROGRAMMING)
ortools：
整数规划求解器，默认使用CBC（Coin-<span class="hljs-keyword">or</span> branch <span class="hljs-keyword">and</span> cut），还包括SCIP、GLPK、Gurobi等
Solver创建
solver = pywraplp.Solver.CreateSolver(<span class="hljs-string">&#x27;SCIP&#x27;</span>)
变量设置
solver.NumVar：创建普通变量
solver.IntVar：创建整数变量

infinity = solver.infinity() <span class="hljs-comment"># 正无穷</span>
x = solver.IntVar(<span class="hljs-number">0.0</span>, infinity, <span class="hljs-string">&#x27;x&#x27;</span>)
print(<span class="hljs-string">&#x27;变量数量：&#x27;</span>, solver.NumVariables())
添加约束条件
solver.Add(x + <span class="hljs-number">7</span> * y &lt;= <span class="hljs-number">17.5</span>)
print(<span class="hljs-string">&#x27;约束的数量：&#x27;</span>, solver.NumConstraints())
Solve求解
<span class="hljs-comment"># 求解最大值问题</span>
solver.Maximize(x + <span class="hljs-number">10</span> * y)
status = solver.Solve()
Solve的结果
print(<span class="hljs-string">&#x27;目标值 =&#x27;</span>, solver.Objective().Value())
print(<span class="hljs-string">&#x27;x =&#x27;</span>, x.solution_value())
print(<span class="hljs-string">&#x27;y =&#x27;</span>, y.solution_value())</code></pre>

<h3 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h3><ul>
<li>1、<a target="_blank" rel="noopener" href="https://cloud.tencent.com/developer/article/1643886">用Python求解线性规划问题</a></li>
<li>2、<a target="_blank" rel="noopener" href="https://www.jianshu.com/p/9be417cbfebb">【数学建模】线性规划各种问题的Python调包方法</a></li>
</ul>
<pre><code class="hljs python"></code></pre>
            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/walker_sue/categories/%E8%BF%90%E7%AD%B9%E5%AD%A6/">运筹学</a>
                    
                      <a class="hover-with-bg" href="/walker_sue/categories/%E8%BF%90%E7%AD%B9%E5%AD%A6/%E8%A7%84%E5%88%92%E9%97%AE%E9%A2%98/">规划问题</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/walker_sue/tags/BI/">BI</a>
                    
                      <a class="hover-with-bg" href="/walker_sue/tags/%E7%BA%BF%E6%80%A7%E8%A7%84%E5%88%92/">线性规划</a>
                    
                      <a class="hover-with-bg" href="/walker_sue/tags/%E8%BF%90%E7%AD%B9%E5%AD%A6/">运筹学</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/walker_sue/2021/06/04/week14-NP2/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">常见规划问题（二）</span>
                        <span class="visible-mobile">Vorheriger</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/walker_sue/2021/05/20/week12-lr-woe/">
                        <span class="hidden-mobile">逻辑回归与评分卡模型评价标准</span>
                        <span class="visible-mobile">Nächster</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;TOC</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Suchen</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">Stichwort</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  

  
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/walker_sue/js/debouncer.js" ></script>
<script  src="/walker_sue/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/walker_sue/js/lazyload.js" ></script>
  



  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/walker_sue/js/clipboard-use.js" ></script>







  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: '#post-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    function typing(id, title){
        var typed = new Typed('#' + id, {
            strings: [
              '  ',
              title + "&nbsp;",
            ],
            cursorChar: "_",
            typeSpeed: 70,
            loop: false,
        });
        typed.stop();
        $(document).ready(function () {
            $(".typed-cursor").addClass("h2");
            typed.start();
        });
    }
    
        typing("subtitle", "常见规划问题（一）")
    
  </script>


  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/walker_sue/js/local-search.js" ></script>
  <script>
    var path = "/walker_sue/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>





  

  
    <!-- MathJax -->
    <script>
      MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']]
        },
        options: {
          renderActions: {
            findScript: [10, doc => {
              document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
                const display = !!node.type.match(/; *mode=display/);
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
                const text = document.createTextNode('');
                node.parentNode.replaceChild(text, node);
                math.start = { node: text, delim: '', n: 0 };
                math.end = { node: text, delim: '', n: 0 };
                doc.math.push(math);
              });
            }, '', false],
            insertedScript: [200, () => {
              document.querySelectorAll('mjx-container').forEach(node => {
                let target = node.parentNode;
                if (target.nodeName.toLowerCase() === 'li') {
                  target.parentNode.classList.add('has-jax');
                }
              });
            }, '', false]
          }
        }
      };
    </script>

    <script async src="https://cdn.staticfile.org/mathjax/3.0.5/es5/tex-svg.js" ></script>

  











</body>
</html>
